package models

import (
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
	"github.com/astaxie/beego"
	"time"
)

func init()  {
	dbhost:=beego.AppConfig.String("mysqlurls")
	dbport:=beego.AppConfig.String("mysqlport")
	dbuser:=beego.AppConfig.String("mysqluser")
	dbpass:=beego.AppConfig.String("mysqlpass")
	dbname:=beego.AppConfig.String("mysqldb")
	dbconn:=dbuser+":"+dbpass+"@tcp("+dbhost+":"+dbport+")/"+dbname+"?charset=utf8"
	orm.RegisterDriver("mysql",orm.DRMySQL)
	orm.RegisterDataBase("default", "mysql", dbconn)
	orm.SetMaxIdleConns("default",30)
	orm.SetMaxOpenConns("default",30)
	orm.DefaultTimeLoc=time.UTC
	orm.Debug=true  //控制台打印sql语句，生产环境下去掉
	orm.RegisterModel(new(ra_user))  //注册数据模型,一定要在init函数内注册，可以多注册，用","分隔
}
